package org.scohen.juploadr.uploadapi;

public class PluginLocator {
    private static ImageUploadApi[] implementations = null;
    public PluginClassLoader loader = new PluginClassLoader();
    private static PluginLocator instance;

    public static PluginLocator getInstance() {
        synchronized (instance) {
            if (instance == null) {
                instance = new PluginLocator();
            }
        }
        return instance;

    }

    protected PluginLocator() {
        implementations = PluginClassLoader.getInstance().getApis();
    }

    public synchronized ImageUploadApi[] getApis() throws NoPluginsFoundException {
        if (implementations == null || implementations.length == 0) {
            throw new NoPluginsFoundException();
        }
        return implementations;
    }

}
